package com.lvan.rabbitboot.routtopic;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author Lvan
 */
@Component
public class RoutTopicConsumer {

    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,
                    exchange = @Exchange(value = "topics", type = ExchangeTypes.TOPIC),
                    key = {"user.save", "user.*.save"}
            )
    })
    public void receive1(String msg) {
        System.out.println("receive-1 : " + msg);
    }

    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,
                    exchange = @Exchange(value = "topics", type = ExchangeTypes.TOPIC),
                    key = {"#.log", "*.log.#"}
            )
    })
    public void receive2(String msg) {
        System.out.println("receive-1 : " + msg);
    }
}
